********************************************************************************************
**** MASTER FILE FOR FOLLOW-UP ANALYSIS
**** This file generates output tables for programme impact effect at follow-up.
**** Version: 16/04/2014
********************************************************************************************

	capture log close
	capture drop _all
	capture program drop _all
	macro drop _all
	clear matrix

	set more off
	set mem 100m
	set matsize 800	
		
	* Set main directory for outputs
			
		cd "/Users/armandalex/Dropbox/Projects/Macedonia paper"
	*	cd "/Users/uctpvle/Dropbox/projet/Macedonia"

	
	* Open dataset

		use "Dataset/Macedonia Household survey.dta", clear	
		
	* Merge with Distances from SWC
	
		merge m:1 samplecode using "Dataset/Distances/Distances from SWC.dta", nogenerate
						
***********************************************************
**** 
**** DEFINE CONTROLS AND GENERAL VARIABLES
**** 
***********************************************************

	* Define controls at household level
	
		global controls_panel "no_educ_head low_primary_head sec_school_head more_sec_head gender_head male_adults ALB TUR OTH ROM d_age_head_l35 d_age_head_35 d_age_head_40 d_age_head_50 d_age_head_55 members_2 members_3 members_4 skopje rural"
		
		global controls "no_educ_head low_primary_head sec_school_head more_sec_head gender_head ALB TUR OTH ROM rel_muslim d_age_head_l35 d_age_head_35 d_age_head_40 d_age_head_50 d_age_head_55 members_2 members_3 members_4 i.id_reg skopje rural lang_rom lang_ser mean_corr"
		
***********************************************************
**** 
**** DEFINE OUTCOMES
**** 
***********************************************************

	* DESCRIPTIVE HOUSEHOLD
	
		global household_char "no_educ_head low_primary_head upp_primary_head sec_school_head more_sec_head gender_head members rural skopje MAC ALB TUR OTH ROM"		

	* EXPENDITURE
				
		global list_household "Expenditure Expenditure_shares Expenditure_adj_shares"
	
			global Expenditure_var 				"expenditure exp_food exp_tobaccoalcohol exp_clothing exp_school exp_health exp_utilities exp_other"
			
				*global Expenditure_food			"exp_food_cereal exp_food_veg exp_food_meat exp_food_fish exp_food_oil exp_food_dairy exp_food_ttea exp_food_ss exp_food_choc exp_food_coffee exp_food_beverages exp_food_outside exp_food_other"
				global Expenditure_food				"exp_food_cereal exp_food_veg exp_food_mfd exp_food_oil exp_food_ctb exp_food_scs exp_food_o"
				global Expenditure_sub				"exp_tobacco exp_alcohol exp_w_clothing exp_h_clothing exp_ch_clothing exp_school_m exp_school_f exp_school_m_0_14 exp_school_f_0_14 exp_school_m_15 exp_school_f_15 exp_health_w exp_health_h exp_health_ch exp_health_other"
	
			global Expenditure_shares_var 		"ln_expenditure sh_food sh_tobaccoalcohol sh_clothing sh_school sh_health sh_utilities sh_other"

				*global Expenditure_shares_food 	"sh_food_cereal sh_food_veg sh_food_meat sh_food_fish sh_food_oil sh_food_dairy sh_food_ttea sh_food_ss sh_food_choc sh_food_coffee sh_food_beverages sh_food_outside sh_food_other"	
				global Expenditure_shares_food		"sh_food_cereal sh_food_veg sh_food_mfd sh_food_oil sh_food_ctb sh_food_scs sh_food_o"
				*global Expenditure_subshares_food 	"ssh_food_cereal ssh_food_veg ssh_food_meat ssh_food_fish ssh_food_oil ssh_food_dairy ssh_food_ttea ssh_food_ss ssh_food_choc ssh_food_coffee ssh_food_beverages ssh_food_outside ssh_food_other"
				global Expenditure_subshares_food 	"ssh_food_cereal ssh_food_veg ssh_food_mfd ssh_food_oil ssh_food_ctb ssh_food_scs ssh_food_o"
				global Expenditure_shares_sub 		"sh_w_clothing sh_h_clothing sh_school_m sh_school_f sh_health_w sh_health_h sh_health_ch sh_health_other"

			global nzero 						"nzero_food nzero_tobaccoalcohol nzero_clothing nzero_school nzero_health nzero_utilities nzero_other"
		
				global nzero_food 					"nzero_food_cereal nzero_food_veg nzero_food_mfd nzero_food_oil nzero_food_ctb nzero_food_scs nzero_food_o"
				global nzero_sub 					"nzero_tobacco nzero_alcohol nzero_w_clothing nzero_h_clothing nzero_ch_clothing nzero_school_m nzero_school_f nzero_school_m_0_14 nzero_school_f_0_14 nzero_school_m_15 nzero_school_f_15 nzero_health_w nzero_health_h nzero_health_ch nzero_health_other"

	* CONSUMPTION
	
			global Cons_shares_var 				"ln_expenditure_adj sh_food_adj sh_tobaccoalcohol_adj sh_clothing_adj sh_school_adj sh_health_adj sh_utilities_adj sh_other_adj"
				
				global Cons_shares_var_pur			"sh_pur_food_adj sh_pur_tobaccoalcohol_adj sh_pur_clothing_adj sh_pur_school_adj sh_pur_health_adj sh_pur_utilities_adj sh_pur_other_adj"
				global Cons_shares_var_sf			"sh_sf_food_adj sh_sf_tobaccoalcohol_adj sh_sf_clothing_adj sh_sf_school_adj sh_sf_health_adj sh_sf_utilities_adj sh_sf_other_adj"				
				global Cons_shares_var_stor			"sh_stor_food_adj sh_stor_tobaccoalcohol_adj sh_stor_clothing_adj sh_stor_school_adj sh_stor_health_adj sh_stor_utilities_adj sh_stor_other_adj"				
				global Cons_shares_var_gift			"sh_gift_food_adj sh_gift_tobaccoalcohol_adj sh_gift_clothing_adj sh_gift_school_adj sh_gift_health_adj sh_gift_utilities_adj sh_gift_other_adj"											
				
			*global Cons_shares_food 		"sh_food_cereal_adj sh_food_veg_adj sh_food_meat_adj sh_food_fish_adj sh_food_oil_adj sh_food_dairy_adj sh_food_ttea_adj sh_food_ss_adj sh_food_choc_adj sh_food_coffee_adj sh_food_beverages_adj sh_food_outside_adj sh_food_other_adj"
			global Cons_shares_food			"sh_food_cereal_adj sh_food_veg_adj sh_food_mfd_adj sh_food_oil_adj sh_food_ctb_adj sh_food_scs_adj sh_food_o_adj"
			*global Cons_subshares_food 	"ssh_food_cereal_adj ssh_food_veg_adj ssh_food_meat_adj ssh_food_fish_adj ssh_food_oil_adj ssh_food_dairy_adj ssh_food_ttea_adj ssh_food_ss_adj ssh_food_choc_adj ssh_food_coffee_adj ssh_food_beverages_adj ssh_food_outside_adj ssh_food_other_adj"
			global Cons_subshares_food		"ssh_food_cereal_adj ssh_food_veg_adj ssh_food_mfd_adj ssh_food_oil_adj ssh_food_ctb_adj ssh_food_scs_adj ssh_food_o_adj"
			global Cons_shares_sub 			"sh_tobacco_adj sh_alcohol_adj sh_w_clothing_adj sh_h_clothing_adj sh_ch_clothing_adj sh_school_m_adj sh_school_f_adj sh_school_m_adj_0_14 sh_school_f_adj_0_14 sh_school_m_adj_15 sh_school_f_adj_15 sh_health_w_adj sh_health_h_adj sh_health_ch_adj sh_health_other_adj"	
	
	* ITEMS	(this is for programs using only the name of the good)
		
			global Items 						"expenditure food tobaccoalcohol clothing school health utilities other"
			
				* Generate labels 
			
					foreach var of newlist food tobaccoalcohol clothing school health utilities other {
						local lab: variable label sh_`var'  /* <- save variable label in local `lab' */
						gen `var' = .
						label var `var' "`lab'"  /* <- store contents of `lab' in */
					}
			
	* TIME USE
			
		global Time_use_m 						"sh_sleeping_m sh_chores_m sh_working_m sh_elderly_m sh_shopping_m sh_leisure_ch_m sh_leisure_no_ch_m sh_study_ch_m sh_other_ch_m sh_other_no_ch_m"
		global Time_use_f 						"sh_sleeping_f sh_chores_f sh_working_f sh_elderly_f sh_shopping_f sh_leisure_ch_f sh_leisure_no_ch_f sh_study_ch_f sh_other_ch_f sh_other_no_ch_f"
	
		
***********************************************************
**** 
**** RUN DO-FILES
**** 
***********************************************************

* New variables and labels
		
		do "Do files/New variables" 															// Produce tables for the descriptive statistics of expenditure at baseline and follow-up
		
		do "Do files/Labels.do" 																// Define variable labels

* Define programs to produce results

		do "Do files/Programs/Treattest.do" 													// Define programs used for table production of mean comparisons
		do "Do files/Programs/Treattest_g.do" 													// Define programs used for table production of mean comparisons by groups
		do "Do files/Programs/Qtreattest.do" 													// Define programs used for table production using quantile regression
		do "Do files/Programs/Exptreattest.do" 													// Define programs used for table production with Terciles comparison
		do "Do files/Programs/Descriptive.do" 													// Define programs used for table production of descriptive for control variables
		
* Expenditure and consumption
		
		do "Do files/Descriptives/Descriptive statistics.do" 									// Produce tables for the descriptive statistics of the sample at baseline and follow-up
		
		do "Do files/Descriptives/Tables for mean comparison.do"								// Produce comparison of treatment groups at baseline and follow-up
		
		*do "Do files/Descriptives/Tables for mean comparison (with bootstrap).do"				// Produce comparison of treatment groups at baseline and follow-up (with bootstrap)
		
		do "Do files/Descriptives/Tables for mean comparison (quantile regression).do"			// Produce comparison of treatment groups at baseline and follow-up (quantile regression)
		
		*do "Do files/Descriptives/Tables for mean comparison (IV).do"							// Produce comparison of treatment groups at baseline and follow-up (IV)
		
		do "Do files/Descriptives/Comparison of non-zeros expenditure" 							// Produce tables for the comparison of non-zeros of expenditure at baseline and follow-up


* Time use

		*do "Do files/Descriptives/Comparison of time use march2014"							// Produce tables for the comparison of time-use at baseline and follow-up
		
* Graphics

		*do "Do files/Graphics.do"																// Produce graphics
